suppressMessages(library(Seurat))
suppressMessages(library(ggplot2))
suppressMessages(library(scater))
suppressMessages(library(SingleCellExperiment))
suppressMessages(library(scran))
srt <- readRDS("/mnt/nmorais-nfs/marta/pB_joana/pC_data/srt-all-samples-after-qc.rds")
srt
## An object of class Seurat 
## 16864 features across 40956 samples within 1 assay 
## Active assay: RNA (16864 features, 3000 variable features)
##  3 dimensional reductions calculated: pca, umap, tsne
table(srt$sample)
## 
## old0 old1 old3 old5  yg0  yg1  yg3  yg5 
## 6199 5596 4650 3995 5524 4434 5550 5008
colorClusters <- c("#6fccc1", "#cf1fa7", "#37ee7c", "#da0322", "#ffd94a", "#207ede", "#fea111", "#b09de9",
                   "#b86fbb", "#150de2", "#ab3f2f", "#d49b6c", "#773aab", "#759474", "#e4b2b8", "#f88a40",
                   "#74b5cf", "#e6208e", "#0a3535", "#5b37c3", "#cc4025", "#d2dc7c", "#344d76", "#ba8b07",
                   "#2e10b6", "#4d0cb0", "#e1668a", "#47a58b", "#d7734a", "#ff58c7", "#edceef", "#a21d59",
                   "#8c8da5", "#ff3e5e", "#688d4b", "#214fca", "#48a8f5", "#752758", "#3b4a4a", "#11674b",
                   "#9a1bd9", "#16146d", "#7d7277", "#2d8cce", "#2460b8", "#0f9a8f", "#b11e90", "#54ed4f",
                   "#987217", "#980119", "#cf0606", "#dd182c", "#88a1e4", "#3b89ba", "#12defd", "#feba3e",
                   "#e31fa5", "#7b3537", "#098a95", "#1f1716", "#df6c94", "#9965ee", "#b438f9", "#0140f5",
                   "#e6c4a8", "#d94f7c", "#0dae56", "#b86d1d", "#0577ad", "#464551", "#6b0959", "#ccf705",
                   "#12271d")

Annotate cells

cell_type <- srt$RNA_snn_res.0.4
cell_type <- gsub("^20$", "Unknown 2" , cell_type)
cell_type <- gsub("^19$","Plasma cells" , cell_type)
cell_type <- gsub("^18$", "Unknown 1" , cell_type)
cell_type <- gsub("^17$", "NK Cells" , cell_type)
cell_type <- gsub("^16$", "mregDCs" , cell_type)
cell_type <- gsub("^15$", "CD11a Myeloid" , cell_type)
cell_type <- gsub("^14$", "Fibrocytes" , cell_type)
cell_type <- gsub("^13$", "Granulocytes" , cell_type)
cell_type <- gsub("^12$", "Proliferating" , cell_type)
cell_type <- gsub("^11$", "B Cells" , cell_type)
cell_type <- gsub("^10$", "ILC2" , cell_type)
cell_type <- gsub("^9$","T Cells" , cell_type)
cell_type <- gsub("^8$","Eosinophils" , cell_type)
cell_type <- gsub("^7$", "cDC1" , cell_type)
cell_type <- gsub("^6$", "DCs injury" , cell_type)
cell_type <- gsub("^5","DCs residentes" , cell_type)
cell_type <- gsub("^4$","Infiltrating Type 2" , cell_type)
cell_type <- gsub("^3$", "Macrophages resident",  cell_type)
cell_type <- gsub("^2$","Infiltrating Type 1" , cell_type)
cell_type <- gsub("^1$", "Macrophages Repair" , cell_type)
cell_type <- gsub("^0$", "Macrophages intermediate" , cell_type)
table(cell_type)
## cell_type
##                  B Cells            CD11a Myeloid                     cDC1 
##                      916                      339                     1299 
##               DCs injury           DCs residentes              Eosinophils 
##                     1705                     2130                     1053 
##               Fibrocytes             Granulocytes                     ILC2 
##                      341                      360                      935 
##      Infiltrating Type 1      Infiltrating Type 2 Macrophages intermediate 
##                     5579                     3924                     9304 
##       Macrophages Repair     Macrophages resident                  mregDCs 
##                     5873                     4516                      303 
##                 NK Cells             Plasma cells            Proliferating 
##                      245                      104                      854 
##                  T Cells                Unknown 1                Unknown 2 
##                      963                      148                       65
srt$cell_type <- cell_type
colors <- c("deeppink", "darkorange4", "blueviolet", "darkorchid1",
            "darkmagenta", "tomato", "lightgoldenrod3", "sienna3",
            "green3", "red", "yellow", "green4", "blue", "navy", "mediumpurple4",
            "grey", "orange3", "black", "orange", "rosybrown1", "rosybrown2"
            )
DimPlot(srt, reduction = "tsne", group.by = "cell_type", cols = colors, pt.size = 1)

Subset macrophages

unique(cell_type)
##  [1] "Macrophages intermediate" "Proliferating"           
##  [3] "Infiltrating Type 1"      "Macrophages Repair"      
##  [5] "DCs injury"               "cDC1"                    
##  [7] "Infiltrating Type 2"      "mregDCs"                 
##  [9] "Unknown 1"                "T Cells"                 
## [11] "CD11a Myeloid"            "DCs residentes"          
## [13] "Macrophages resident"     "Eosinophils"             
## [15] "B Cells"                  "Fibrocytes"              
## [17] "ILC2"                     "Granulocytes"            
## [19] "Unknown 2"                "NK Cells"                
## [21] "Plasma cells"
keep_macs <- c("Macrophages intermediate", "Macrophages Repair", "Infiltrating Type 2",
               "Infiltrating Type 1", "CD11a Myeloid" )
srt_mac <- srt[, srt$cell_type %in% keep_macs & srt$condition == "Young"]
srt_mac
## An object of class Seurat 
## 16864 features across 12313 samples within 1 assay 
## Active assay: RNA (16864 features, 3000 variable features)
##  3 dimensional reductions calculated: pca, umap, tsne
table(srt_mac$cell_type, srt_mac$condition)
##                           
##                            Young
##   CD11a Myeloid              111
##   Infiltrating Type 1       2034
##   Infiltrating Type 2       1961
##   Macrophages intermediate  4984
##   Macrophages Repair        3223
mac_colors <- c("darkorange4","red", "yellow", "green4", "blue", "navy" )
DimPlot(srt_mac, reduction = "tsne", group.by = "cell_type", cols = colors <- mac_colors, pt.size = 1)

sce <- readRDS("/mnt/nmorais-nfs/marta/pB_joana/pC_data/sce_all-samples-after-qc.rds")
sce$cell_type <- srt$cell_type
table(sce$condition, srt$condition)
##        
##           Old Young
##   Old   20440     0
##   Young     0 20516
sce_macs <- sce[, srt$cell_type %in% keep_macs & srt$condition == "Young"]
sce_macs
## class: SingleCellExperiment 
## dim: 16864 12313 
## metadata(0):
## assays(3): counts logcounts limma
## rownames(16864): Xkr4 Mrpl15 ... CAAA01147332.1 AC149090.1
## rowData names(0):
## colnames(12313): AAACCCAAGGGTTAAT-1 AAACCCACAAGTACCT-1 ...
##   TTTGATCGTTGCTCAA-1 TTTGATCGTTTCTTAC-1
## colData names(18): total_counts log10_total_counts ... doublet
##   cell_type
## reducedDimNames(0):
## mainExpName: NULL
## altExpNames(0):
table(sce_macs$cell_type, sce_macs$condition)
##                           
##                            Young
##   CD11a Myeloid              111
##   Infiltrating Type 1       2034
##   Infiltrating Type 2       1961
##   Macrophages intermediate  4984
##   Macrophages Repair        3223

Perform library size normalization

mat <- assays(sce_macs)$counts
dim(mat)
## [1] 16864 12313
mat[1:5,1:5]
## 5 x 5 sparse Matrix of class "dgCMatrix"
##        AAACCCAAGGGTTAAT-1 AAACCCACAAGTACCT-1 AAACCCATCATGCTAG-1
## Xkr4                    .                  .                  .
## Mrpl15                  .                  1                  1
## Lypla1                  .                  2                  .
## Tcea1                   1                  2                  1
## Rgs20                   .                  .                  .
##        AAACGAACAGCTGGTC-1 AAACGCTAGTCATACC-1
## Xkr4                    .                  .
## Mrpl15                  .                  1
## Lypla1                  1                  1
## Tcea1                   4                  4
## Rgs20                   .                  .
gene_sum <- rowSums(mat)
gene_sum[1:5]
##   Xkr4 Mrpl15 Lypla1  Tcea1  Rgs20 
##    112   5443   5529  16565    149
mat <- mat[gene_sum >= 0,]
dim(mat)
## [1] 16864 12313
sce_macs <- sce_macs[gene_sum >= 0,]
total_counts <- colSums(mat)
total_counts[1:5]
## AAACCCAAGGGTTAAT-1 AAACCCACAAGTACCT-1 AAACCCATCATGCTAG-1 AAACGAACAGCTGGTC-1 
##               8691              12852               6544              20761 
## AAACGCTAGTCATACC-1 
##              15778
total_features <- c()
for (cell in colnames(sce_macs)){total_features <- c(total_features, sum(mat[,cell] > 0))}
total_features[1:5]
## [1] 2415 3393 2233 4163 3773
saveRDS(total_features, "/mnt/nmorais-nfs/marta/pB_joana/pC_data/total_features-mono-macs-young-without-residents.rds")
logmat <- log2(mat+1)
## Warning in asMethod(object): sparse->dense coercion: allocating vector of size
## 1.5 GiB
df1 <- data.frame(total_counts = total_counts,
                 total_features = total_features,
                 sample = sce_macs$sample,
                 sorting = sce_macs$sorting_day,
                 lane = sce_macs$lane)

df2 <- data.frame(sample = sce_macs$sample,
                 log2_total_features = log2(total_features),
                 log2_total_counts = log2(total_counts))

varMatrix <- getVarianceExplained(mat, variables = df1)
logVarMatrix <- getVarianceExplained(logmat, variables = df1)

plotExplanatoryVariables(
            varMatrix,
            variables = variables)  + 
  ggtitle("Young - Mono/macs") +
  theme(text = element_text(size=20)) +
 scale_color_manual(values=c( "dodgerblue" ,"purple" , "green3","orange", "blue", "red"))
## Scale for 'colour' is already present. Adding another scale for 'colour',
## which will replace the existing scale.
## Warning: Removed 245 rows containing non-finite values (stat_density).

          plotExplanatoryVariables(
            logVarMatrix,
            exprs_values="logcounts",
            variables = variables)  + 
            
  ggtitle("Young - Mono/macs") +
  theme(text = element_text(size=20)) +
 scale_color_manual(values=c("dodgerblue" ,"purple" , "green3","orange", "blue")) 
## Scale for 'colour' is already present. Adding another scale for 'colour',
## which will replace the existing scale.
## Warning: Removed 245 rows containing non-finite values (stat_density).

make_barplot <- function(df, x, y, title = "Young - Mono/macs", ylab){
  ggplot(df, aes(x=x, y=y, fill=sample)) +
  
  geom_boxplot(show.legend = FALSE) + 
  theme_bw() +
  theme(text = element_text(size=20), axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1)) +
  ylab(ylab) + xlab("Sample") +
    ggtitle(title)
}

make_barplot(df1, df1$sample, df1$total_counts, ylab =  "Library size")

make_barplot(df2, df2$sample, df2$log2_total_counts, ylab =  "Library size (log2)") 

make_barplot(df1, df1$sample, df1$total_features, ylab =  "Total features")

make_barplot(df2, df2$sample, df2$log2_total_features, ylab =  "Total features (log2)")

qclust <- quickCluster(sce_macs)
sce <- computeSumFactors(sce_macs, clusters=qclust)      
summary(sizeFactors(sce_macs))   
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.1726  0.8203  1.0728  1.1418  1.3824  4.1643
sce <- logNormCounts(sce_macs, 
                     size_factors = sizeFactors(sce_macs),
                     log = TRUE,
                     pseudo_count = 1, 
                     exprs_values = "counts"
                     )
sce_macs
## class: SingleCellExperiment 
## dim: 16864 12313 
## metadata(0):
## assays(3): counts logcounts limma
## rownames(16864): Xkr4 Mrpl15 ... CAAA01147332.1 AC149090.1
## rowData names(0):
## colnames(12313): AAACCCAAGGGTTAAT-1 AAACCCACAAGTACCT-1 ...
##   TTTGATCGTTGCTCAA-1 TTTGATCGTTTCTTAC-1
## colData names(18): total_counts log10_total_counts ... doublet
##   cell_type
## reducedDimNames(0):
## mainExpName: NULL
## altExpNames(0):
mat <- assays(sce_macs)$logcounts
total_counts <- colSums((2**mat)-1)
## Warning in asMethod(object): sparse->dense coercion: allocating vector of size
## 1.5 GiB
total_counts[1:5]
## AAACCCAAGGGTTAAT-1 AAACCCACAAGTACCT-1 AAACCCATCATGCTAG-1 AAACGAACAGCTGGTC-1 
##           13227.27           10872.45           11450.98           10965.41 
## AAACGCTAGTCATACC-1 
##           11299.45
mat[1:5,1:5]
## 5 x 5 sparse Matrix of class "dgCMatrix"
##        AAACCCAAGGGTTAAT-1 AAACCCACAAGTACCT-1 AAACCCATCATGCTAG-1
## Xkr4              .                .                   .       
## Mrpl15            .                0.8843815           1.459349
## Lypla1            .                1.4286495           .       
## Tcea1             1.33454          1.4286495           1.459349
## Rgs20             .                .                   .       
##        AAACGAACAGCTGGTC-1 AAACGCTAGTCATACC-1
## Xkr4            .                  .        
## Mrpl15          .                  0.7791778
## Lypla1          0.6118084          0.7791778
## Tcea1           1.6381639          1.9503228
## Rgs20           .                  .
((2**mat)-1)[1:5,1:5]
## Warning in asMethod(object): sparse->dense coercion: allocating vector of size
## 1.5 GiB
## 5 x 5 Matrix of class "dgeMatrix"
##        AAACCCAAGGGTTAAT-1 AAACCCACAAGTACCT-1 AAACCCATCATGCTAG-1
## Xkr4              0.00000          0.0000000           0.000000
## Mrpl15            0.00000          0.8459731           1.749843
## Lypla1            0.00000          1.6919461           0.000000
## Tcea1             1.52195          1.6919461           1.749843
## Rgs20             0.00000          0.0000000           0.000000
##        AAACGAACAGCTGGTC-1 AAACGCTAGTCATACC-1
## Xkr4            0.0000000          0.0000000
## Mrpl15          0.0000000          0.7161525
## Lypla1          0.5281736          0.7161525
## Tcea1           2.1126943          2.8646100
## Rgs20           0.0000000          0.0000000
df3 <- data.frame(total_counts = total_counts,
                 sample = sce_macs$sample,
                 sorting = sce_macs$sorting_day,
                 lane = sce_macs$lane,
                 condition = sce$condition)

df4 <- data.frame(
                 log2_total_counts = log2(total_counts),
                 #log2_total_features = log2(total_features),
                 sample = sce_macs$sample)

make_barplot(df3, df3$sample, df3$total_counts, ylab =  "Library size") +ylim(0, 50000)

make_barplot(df4, df4$sample, df4$log2_total_counts, ylab =  "Library size (log2)") +ylim(11.5,15.5)

normVarMatrix <- getVarianceExplained(assays(sce_macs)$logcounts, variables = df3[,c("total_counts", "sample", "sorting", "condition")])
## Warning in beachmat_internal_FUN(X[[3]], ...): ignoring 'condition' with fewer
## than 2 unique levels
          plotExplanatoryVariables(
            normVarMatrix,
            variables = variables)  + 
  ggtitle("Young - Mono/macs") +
  theme(text = element_text(size=20)) +
 scale_color_manual(values=c("dodgerblue" ,"purple" , "green3","orange", "blue", "red"))
## Scale for 'colour' is already present. Adding another scale for 'colour',
## which will replace the existing scale.
## Warning: Removed 17011 rows containing non-finite values (stat_density).

assays(sce_macs)$limma <- NULL
saveRDS(sce_macs, "/mnt/nmorais-nfs/marta/pB_joana/pC_data/sce-mono-macs-young-without-residents.rds")

Create new seurat object

norm_mat <- (2**assays(sce_macs)$logcounts)-1
## Warning in asMethod(object): sparse->dense coercion: allocating vector of size
## 1.5 GiB
ln_mat <- log(norm_mat + 1)
srt_subset <- CreateSeuratObject(counts = ln_mat, min.cells = 0, min.features = 0)
## Warning: Non-unique features (rownames) present in the input matrix, making
## unique
## Warning: Non-unique cell names (colnames) present in the input matrix, making
## unique
srt_subset
## An object of class Seurat 
## 16864 features across 12313 samples within 1 assay 
## Active assay: RNA (16864 features, 0 variable features)
srt_subset <- FindVariableFeatures(srt_subset, selection.method = "vst", nfeatures = 3000)
# Identify the 20 most highly variable genes
top20 <- head(VariableFeatures(srt_subset), 20)

# plot variable features with and without labels
plot1 <- VariableFeaturePlot(srt_subset)
plot2 <- LabelPoints(plot = plot1, points = top20, repel = TRUE)
## When using repel, set xnudge and ynudge to 0 for optimal results
plot2
## Warning: Transformation introduced infinite values in continuous x-axis
## Warning: Removed 49 rows containing missing values (geom_point).

all.genes <- rownames(srt_subset)
srt_subset <- ScaleData(srt_subset, features = all.genes)
## Centering and scaling data matrix
srt_subset <- RunPCA(srt_subset, features = VariableFeatures(object = srt_subset), npcs = 100)
## PC_ 1 
## Positive:  Itm2b, Apoe, Selenop, Pltp, C1qc, C1qb, C1qa, Timp2, Ms4a7, Hexa 
##     Rgs10, Hexb, Ctsh, Trem2, Arhgap22, Tmcc3, Tmem86a, Tnfaip8l2, Frmd4b, Otulinl 
##     Itga9, Ypel3, Cxcl16, Gm10076, Fcrls, Cox7a2l, Mertk, Serpinb6a, Abcg1, Ptms 
## Negative:  Clec4e, Clec4d, Pim1, Fn1, Ehd1, Thbs1, Ccl6, Vcan, Ccl9, Ahnak 
##     S100a6, Rab11fip1, Ppp4r2, Cd14, Sod2, F10, S100a4, Adora2b, Pkm, Emilin2 
##     S100a10, Lilrb4a, Cxcl2, Plcb1, Ptgs2, Gda, Por, Chil3, Mdm2, Ccr1 
## PC_ 2 
## Positive:  Plbd1, Ly6e, Cd74, Plac8, Arhgap15, Samhd1, Dleu2, Ifitm6, Gpr141, Etv6 
##     Ifi209, Btg2, Sik3, Arhgap26, Napsa, Ccr2, Cybb, H2-Ab1, Txnip, H2-Eb1 
##     Ccnd3, Ms4a4c, Ifi213, H2-Aa, Ptprj, Cd52, A330040F15Rik, Sell, Mndal, Sp140 
## Negative:  Ctsd, Ctsb, Fabp5, Lgals1, Ctsl, Cd63, Cd68, Pf4, Spp1, Ftl1 
##     Gpnmb, Aprt, Trem2, Syngr1, Grn, Vat1, Cstb, Lhfpl2, Slc6a8, Arhgap10 
##     Emp1, Cd93, Lgals3, Pgam1, Cd36, Fth1, Gde1, Capg, Ms4a7, Timp2 
## PC_ 3 
## Positive:  Tmsb10, S100a6, S100a4, Rnh1, Ifitm3, Ly6c2, Lgals3, Ms4a4c, Plac8, Lsp1 
##     Msrb1, Crip1, Capg, Zbp1, S100a11, Lgals1, Ifi204, Sell, Bst2, Phf11b 
##     Isg15, Ifi27l2a, Ifitm6, Txn1, Anxa2, Samhd1, Ifi209, Cd68, Oas3, Hp 
## Negative:  Tnfaip3, Nfkbiz, Tnf, Nfkb1, Cxcl2, Gm15726, Nfkbia, Mthfs, Cd83, Nlrp3 
##     Sdc4, Abca1, Bcl2a1b, Maff, Rapgef2, Kansl1l, Hivep2, Kctd12, Tank, Sash1 
##     Junb, Gadd45b, Ccrl2, Kdm6b, Pde4b, Phlda1, Il10, Nrp2, Mir155hg, Ptprj 
## PC_ 4 
## Positive:  Cytip, Xylt1, Fyn, Runx3, Gpr132, Antxr2, Nfe2l2, Pde3b, Nuak2, Arl4c 
##     Gsr, Itgal, Csf2rb, Sorl1, Trps1, Gngt2, Havcr2, Ace, Itgax, Crem 
##     Mxi1, Nfil3, Plxnc1, Mrtfa, Lmnb1, Gcnt2, Stap1, Gfod1, Tspan13, Runx2 
## Negative:  Isg15, Fcgr1, Ccl2, Rsad2, Ifi211, Ccl7, Ifit3, Slfn5, Ccl12, Oasl2 
##     Usp18, Oasl1, Irf7, Zbp1, Ifit2, Ifit1, Ifi204, Slfn4, Ifi203, Ifi205 
##     Mndal, Phf11d, Phf11b, Rnf213, Slfn1, Ifi209, Bst2, Trim30a, Ifi47, Rtp4 
## PC_ 5 
## Positive:  Pid1, Ccnb1ip1, Zswim6, Gm26917, Zfp608, Txnip, F13a1, Anxa2, Gm26887, Fn1 
##     Grk5, Camk1d, Peak1, Thbs3, Cmss1, Dand5, Baiap2, Tmem164, Dlg4, Fbxl18 
##     Dleu2, Pecam1, Slc7a5, Sgms1, Zfp710, Ints6, S100a4, Ahnak, Pde4c, S100a10 
## Negative:  Irf7, Bst2, Ifit3, Rsad2, Lgals3bp, Axl, Cd52, Ifit2, Phf11b, Oasl2 
##     Isg15, H2-Aa, Ms4a4c, AW112010, Aif1, Slamf7, H2-Ab1, Ifi47, Fth1, Oas3 
##     H2-Eb1, Mndal, Cd74, Ly6e, Fcgr4, Slfn5, Ifi211, Znfx1, Trim30a, Ly6a
ElbowPlot(srt_subset, ndims = 100) + 
  geom_vline(xintercept = 25, color = "red", alpha = 0.5) + 
  theme(text = element_text(size = 10), 
        axis.text.x = element_text(size = 10),
        axis.text.y = element_text(size = 10))

srt_subset$sample <- sce_macs$sample
srt_subset$lane <- sce_macs$lane
srt_subset$sorting_day <- sce_macs$sorting_day
srt_subset$cell_type <- sce_macs$cell_type
DimPlot(srt_subset, reduction = "pca", group.by = "cell_type", cols = mac_colors)

srt_subset <- RunUMAP(srt_subset, n.components = 10, features = VariableFeatures(srt_subset))
## Warning: The default method for RunUMAP has changed from calling Python UMAP via reticulate to the R-native UWOT using the cosine metric
## To use Python UMAP via reticulate, set umap.method to 'umap-learn' and metric to 'correlation'
## This message will be shown once per session
## 17:43:52 UMAP embedding parameters a = 0.9922 b = 1.112
## 17:43:52 Read 12313 rows and found 3000 numeric columns
## 17:43:52 Using Annoy for neighbor search, n_neighbors = 30
## 17:43:52 Building Annoy index with metric = cosine, n_trees = 50
## 0%   10   20   30   40   50   60   70   80   90   100%
## [----|----|----|----|----|----|----|----|----|----|
## **************************************************|
## 17:44:03 Writing NN index file to temp file /tmp/Rtmpz4hIrB/file66be2a68b65a
## 17:44:03 Searching Annoy index using 1 thread, search_k = 3000
## 17:46:39 Annoy recall = 100%
## 17:46:40 Commencing smooth kNN distance calibration using 1 thread with target n_neighbors = 30
## 17:46:42 Initializing from normalized Laplacian + noise (using irlba)
## 17:46:42 Commencing optimization for 200 epochs, with 663648 positive edges
## 17:46:53 Optimization finished
DimPlot(srt_subset, reduction = "umap", group.by = "cell_type", cols = mac_colors)

srt_subset <- RunTSNE(srt_subset,
             dim.embed = 3,
            dims = 1:25)
DimPlot(srt_subset, reduction = "tsne", group.by = "cell_type", cols = mac_colors)

DimPlot(srt_subset, reduction = "tsne", group.by = "sample", cols = mac_colors)

DimPlot(srt_subset, reduction = "tsne", group.by = "sorting_day", cols = mac_colors)

DimPlot(srt_subset, reduction = "tsne", group.by = "lane", cols = mac_colors)

saveRDS(srt_subset, "/mnt/nmorais-nfs/marta/pB_joana/pC_data/srt-mono-macs-young-without-residents.rds")
sessionInfo()
## R version 4.1.2 (2021-11-01)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 18.04.6 LTS
## 
## Matrix products: default
## BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
## LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## attached base packages:
## [1] stats4    stats     graphics  grDevices utils     datasets  methods  
## [8] base     
## 
## other attached packages:
##  [1] scran_1.22.1                scater_1.22.0              
##  [3] scuttle_1.4.0               SingleCellExperiment_1.16.0
##  [5] SummarizedExperiment_1.24.0 Biobase_2.54.0             
##  [7] GenomicRanges_1.46.1        GenomeInfoDb_1.30.1        
##  [9] IRanges_2.28.0              S4Vectors_0.32.4           
## [11] BiocGenerics_0.40.0         MatrixGenerics_1.6.0       
## [13] matrixStats_0.62.0          ggplot2_3.3.6              
## [15] SeuratObject_4.1.3          Seurat_4.1.0               
## 
## loaded via a namespace (and not attached):
##   [1] plyr_1.8.7                igraph_1.3.5             
##   [3] lazyeval_0.2.2            sp_1.5-0                 
##   [5] splines_4.1.2             BiocParallel_1.28.3      
##   [7] listenv_0.8.0             scattermore_0.8          
##   [9] digest_0.6.30             htmltools_0.5.3          
##  [11] viridis_0.6.2             fansi_1.0.3              
##  [13] magrittr_2.0.3            ScaledMatrix_1.2.0       
##  [15] tensor_1.5                cluster_2.1.4            
##  [17] ROCR_1.0-11               limma_3.50.3             
##  [19] globals_0.16.1            spatstat.sparse_3.0-0    
##  [21] colorspace_2.0-3          ggrepel_0.9.1            
##  [23] xfun_0.34                 dplyr_1.0.10             
##  [25] RCurl_1.98-1.9            jsonlite_1.8.3           
##  [27] progressr_0.11.0          spatstat.data_3.0-0      
##  [29] survival_3.4-0            zoo_1.8-11               
##  [31] glue_1.6.2                polyclip_1.10-4          
##  [33] gtable_0.3.1              zlibbioc_1.40.0          
##  [35] XVector_0.34.0            leiden_0.4.3             
##  [37] DelayedArray_0.20.0       BiocSingular_1.10.0      
##  [39] future.apply_1.9.1        abind_1.4-5              
##  [41] scales_1.2.1              edgeR_3.36.0             
##  [43] DBI_1.1.3                 spatstat.random_3.0-1    
##  [45] miniUI_0.1.1.1            Rcpp_1.0.9               
##  [47] viridisLite_0.4.1         xtable_1.8-4             
##  [49] dqrng_0.3.0               reticulate_1.26          
##  [51] spatstat.core_2.4-4       rsvd_1.0.5               
##  [53] metapod_1.2.0             htmlwidgets_1.5.4        
##  [55] httr_1.4.4                RColorBrewer_1.1-3       
##  [57] ellipsis_0.3.2            ica_1.0-3                
##  [59] farver_2.1.1              pkgconfig_2.0.3          
##  [61] sass_0.4.2                uwot_0.1.14              
##  [63] deldir_1.0-6              locfit_1.5-9.6           
##  [65] utf8_1.2.2                labeling_0.4.2           
##  [67] tidyselect_1.2.0          rlang_1.0.6              
##  [69] reshape2_1.4.4            later_1.3.0              
##  [71] munsell_0.5.0             tools_4.1.2              
##  [73] cachem_1.0.6              cli_3.4.1                
##  [75] generics_0.1.3            ggridges_0.5.4           
##  [77] evaluate_0.17             stringr_1.4.1            
##  [79] fastmap_1.1.0             yaml_2.3.6               
##  [81] goftest_1.2-3             knitr_1.40               
##  [83] fitdistrplus_1.1-8        purrr_0.3.5              
##  [85] RANN_2.6.1                sparseMatrixStats_1.6.0  
##  [87] pbapply_1.5-0             future_1.28.0            
##  [89] nlme_3.1-160              mime_0.12                
##  [91] compiler_4.1.2            rstudioapi_0.14          
##  [93] beeswarm_0.4.0            plotly_4.10.0            
##  [95] png_0.1-7                 spatstat.utils_3.0-1     
##  [97] statmod_1.4.37            tibble_3.1.8             
##  [99] bslib_0.4.0               stringi_1.7.8            
## [101] highr_0.9                 bluster_1.4.0            
## [103] lattice_0.20-45           Matrix_1.5-1             
## [105] vctrs_0.5.0               pillar_1.8.1             
## [107] lifecycle_1.0.3           spatstat.geom_3.0-3      
## [109] lmtest_0.9-40             jquerylib_0.1.4          
## [111] BiocNeighbors_1.12.0      RcppAnnoy_0.0.19         
## [113] data.table_1.14.4         cowplot_1.1.1            
## [115] bitops_1.0-7              irlba_2.3.5.1            
## [117] httpuv_1.6.6              patchwork_1.1.2          
## [119] R6_2.5.1                  promises_1.2.0.1         
## [121] KernSmooth_2.23-20        gridExtra_2.3            
## [123] vipor_0.4.5               parallelly_1.32.1        
## [125] codetools_0.2-18          MASS_7.3-58.1            
## [127] assertthat_0.2.1          withr_2.5.0              
## [129] sctransform_0.3.5         GenomeInfoDbData_1.2.7   
## [131] mgcv_1.8-41               parallel_4.1.2           
## [133] beachmat_2.10.0           grid_4.1.2               
## [135] rpart_4.1.19              tidyr_1.2.1              
## [137] DelayedMatrixStats_1.16.0 rmarkdown_2.17           
## [139] Rtsne_0.16                shiny_1.7.2              
## [141] ggbeeswarm_0.6.0